#include<arbb.hpp>
#include<iostream>
using namespace arbb;

void Matrix_Fill(dense<i32,2> & M, i32 n)
{
   _for(i32 i=1,i<(n-1),i++)
    {
      _for(i32 j=1,j<(n-1),j++)
	{
	  i32 w=i*n+j;
	  i32 w1=(i-1)*n+j;
	  i32 w2=(i-1)*n+(j-1);
	  i32 w3=(i-1)*n+(j+1);
	  i32 w4=i*n+(j-1);
	  i32 w5=i*n+(j+1);
	  i32 w6=(i+1)*n+(j-1);
	  i32 w7=(i+1)*n+j;
	  i32 w8=(i+1)*n+(j+1);
	  M(w,w1)=1;
	  M(w,w2)=1;
	  M(w,w3)=1;
	  M(w,w4)=1;
	  M(w,w5)=1;
	  M(w,w6)=1;
	  M(w,w7)=1;
	  M(w,w8)=1;
	}_end_for;
    }_end_for;
}

void first(dense<i32,2> & Matrix, i32 numVertex, i32 v, i32 & k) {            // Return v's first neighbor
  std::cout<<"Hello"<<std::endl;
  i32 i;
  _for (i=0, i<numVertex, i++){
    _if (Matrix(v,i) != 0) {
      //	std::cout<<"First neighbor:"<<value(i)<<std::endl;
      k=i;
      return;
    }_end_if;
  }_end_for;
  k=i;
  return;       // Return n if none
}

i32 next(dense<i32,2> & Matrix, i32 numVertex,i32 v1, i32 v2) { // Get v1's neighbor after v2
  i32 i;
  _for(i=v2+1, i<numVertex, i++){
    _if (Matrix(v1,i) != 0){
      return i;
    }_end_if;
  }_end_for;
  return i;
}

void DFS(dense<i32,2> & Matrix, dense<i32> & Mark, i32 numVertex, i32 vertex)
{
  boolean t=false;
  Mark[vertex]=1;
  //std::cout<<"vertex: "<<value(vertex)<<std::endl;
  i32 w=0;
  i32 k=0;
  first(Matrix,numVertex,vertex,k);
  std::cout<<"Hello"<<std::endl;
  _for(w=k,w<numVertex,w=w+1)
    {
      //z=next(Matrix,numVertex,vertex,w);
      //std::cout<<"Hello"<<std::endl;
      _if(Mark[w] == 0)
	{
	  t=true;
	  //DFS(Matrix,Mark,numVertex,w);
	}_end_if;
    }_end_for;
}
